<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ include file="/v1/h5/pages/public/head.jsp"%>

<!-- 编辑收货地址 -->

<div id="ldhEditAdress">
	<!-- 接受参数 -->
	<input type="hidden" id="provinceId" value="${param.provinceId}" />
	<input type="hidden" id="cityId" value="${param.cityId}" />
	<input type="hidden" id="regionId" value="${param.regionId}" />
	<input type="hidden" id="addressId" value="${param.addressId}" />
	<div data-role="header" class="header_fixed">
    	<a data-role="none" data-rel="back" class="back_btn">返回</a>
    	<h1>编辑收货地址</h1>
    </div>
    <div data-role="content">
    	<div class="new_address">
        	<ul>  
            	<li class="li_input clearfix"><label>联系人</label><input type="text" data-role="none" placeholder="联系人姓名" name="shipName" /></li>
                <li class="li_input clearfix"><label>手机号码</label><input type="text" data-role="none" placeholder="联系人手机" name="ship_mobile"/></li>
                <li class="li_click clearfix"><label>所在区域</label><span onclick="jumpProvinceList()">请选择所在区域</span></li>
                <li class="li_input clearfix"><label>收货地址</label><input type="text" data-role="none" placeholder="请输入收货地址" name="ship_address"/></li>
            </ul>
             
        </div>
        <div class="setting_address"><input type="checkbox" name="def" data-role="none" checked="checked"><span>设为默认地址</span></div>
        <div class="login_btn" style="margin:10px 10px;"><button type="button" data-role="none" onClick="$ldh_user.saveAddress(1)">保存</button></div>
        <div class="new_address_tip">
        	<span>地址请尽量详细，如xx大楼xx室</span>
        </div>
    </div>
      <script type="text/javascript">
      var addressId='${param.addressId}';
    	seajs.use([ctx+'/v1/h5/js/custom/ucenter/module-ucenter.js?'+Date.parse(new Date())],function(m){
		m.init(m);
		
		if($("#provinceId").val()!="" && $("#cityId").val()!=""  && $("#regionId").val()!=""){
			
			$("#ldhEditAdress input[name=ship_mobile]").val($ldh_base.getCookie("ship_mobile"))
			$("#ldhEditAdress input[name=shipName]").val($ldh_base.getCookie("shipName"))
			if($ldh_base.getCookie("provinceName")!=""){
				$("#ldhEditAdress .new_address .li_click span").html($ldh_base.getCookie("provinceName")+" "+$ldh_base.getCookie("cityName")+" "+$ldh_base.getCookie("regionName"));
			}
			
			$("#ldhEditAdress input[name=ship_address]").val($ldh_base.getCookie("ship_address"))
			
				$ldh_base.setCookie("provinceId",$("#provinceId").val());
		 		$ldh_base.setCookie("cityId",$("#cityId").val());
		 		$ldh_base.setCookie("regionId",$("#regionId").val()); 
			
		}else{
			
			m.loadAddress(addressId);
		}
		
		
	});
 	document.title="云便利-编辑收货地址";
 	//跳转到省份列表
 	function jumpProvinceList(){
 		
 		window.location.href=ctx+"/h5/provinceList.shtml";
 		
 	    $ldh_base.setCookie("ship_address",$("#ldhEditAdress input[name=ship_address]").val());
 		$ldh_base.setCookie("ship_mobile",$("#ldhEditAdress input[name=ship_mobile]").val());
 		$ldh_base.setCookie("shipName",$("#ldhEditAdress input[name=shipName]").val());
 		//$ldh_base.setCookie("memo",$("#ldhNewAdress .new_address .li_click span").html()+" "+$("#ldhNewAdress input[name=ship_address]").val());
 		$ldh_base.setCookie("provinceId",$("#provinceId").val());
 		$ldh_base.setCookie("cityId",$("#cityId").val());
 		$ldh_base.setCookie("regionId",$("#regionId").val()); 
		
 	}
    </script>
</div>

<%@ include file="/v1/h5/pages/public/footer.jsp"%>
